<template>
	<view class="content">
		<base-headers/>
		<!-- 首页轮播 -->
		<view style="height: 28rpx;"></view>
		<base-swiper v-if="isSwiper" :data="coloegesSwipers" :swiperLength="swiperLength" isSchool="true"/>
		<!-- 院校列表 -->
		<view class="school">

			<view class="school-title">
				院校列表
			</view>
			<view class="school-info" v-for="item in schoolData" :key="item.id" @click="toUrl(item.id)">
				<view class="school-info-left">
					<image :src="'https://fetv.cn/fetv-api/'+item.firstImage" style="width: 262upx;height: 212upx;"></image>
				</view>
				<view class="school-info-right">
					<view class="school-name">
						{{item.schoolName}}
					</view>
					<view class="school-icon-box">
						<view v-if="item.label" class="school-icon" v-for="i in item.label" :key="i">
							{{i}}
						</view>
					</view>
					<view class="school-res">
						{{item.synopsis}}
					</view>
					<view class="school-more">
						<text>了解更多</text>
						<image src="../../static/more.png" style="width:15px;height: 15px; margin-left: 10px;">
						</image>
					</view>
				</view>
			</view>

		<top-button :top="top"/>
		</view>

	</view>
</template>

<script>
	import {
		getAllSchoool,
		getTopSchoool
	} from '../../api/school'
import { debounce } from '../../utils/util'
	export default {
		data() {
			return {
				schoolData: [],
				coloegesSwipers: [],
				swiperLength: 0,
				isSwiper: false,
				top:0
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData(id) {
				getTopSchoool().then(res => {
					this.coloegesSwipers = res.data
					this.swiperLength = res.data.length
					this.isSwiper = true
				})

				getAllSchoool({
					pageNum:1,
					pageSize:10
				}).then(res => {
					this.schoolData = res.data
					console.log(res);
					this.schoolData.forEach((item, index) => {
						if (item.label) {
							this.schoolData[index].label = item.label.split(',')
						}
					})
				})
			},
			toUrl(id) {
				uni.navigateTo({
					url: '../../subpages/shool-info/shool-info?id='+id
				})
			}
		},
		onPageScroll(e) {
			debounce(()=>{
				this.top = e.scrollTop
			})
		},
	}
</script>

<style lang="scss" scoped>
	.content {}

	// 首页轮播图
	.img-box {
		position: relative;
		top: 41upx;
		left: 25upx;

		.content_img {
			width: 700upx;
			height: 423upx;
			overflow: hidden;
			border-radius: 12upx;
		}

		.shadow-box {
			position: absolute;
			bottom: 4px;
			background-color: #000000;
			opacity: 0.45;
			width: 700upx;
			height: 70upx;
			border-radius: 0 0 12upx 12upx;

		}

		.shadow-text {
			display: flex;
			align-items: center;
			position: absolute;
			bottom: 0;
			color: #ffffff;
			left: 23upx;
			height: 88upx;
			line-height: 60upx;

			.swiper-number {
				margin-right: 280upx;

				.size-small {
					font-size: 24upx
				}
			}
		}
	}

	.school {

		width: 704upx;
		margin-left: 21upx;

		.school-title {
			font-size: 34upx;
			font-family: Noto Sans S Chinese;
			font-weight: bold;
			color: #272727;
			margin-bottom: 20upx;
		}

		.school-info {
			display: flex;
			margin-top: 20upx;
			padding-bottom: 20upx;
			border-bottom: 1px solid #F4F4F4;

			.school-info-right {
				position: relative;
				margin-left: 20upx;
				display: flex;
				flex-direction: column;
				width: 100%;

				.school-name {
					font-size: 30upx;
					font-family: Noto Sans S Chinese;
					font-weight: bold;
					color: #272727;
				}

				.school-res {
					width: 420rpx;
					margin-top: 28upx;
					font-size: 24upx;
					font-family: Noto Sans S Chinese;
					font-weight: 400;
					color: #676767;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;

				}

				.school-icon-box {
					display: flex;

					.school-icon {
						font-size: 22upx;
						font-family: Noto Sans S Chinese;
						font-weight: 400;
						color: #BA0825;
						background-color: rgba(186, 8, 37, 0.15);
						padding: 4upx 10upx;
						margin-right: 10upx;
						margin-top: 20upx;
					}
				}

				.school-more {
					position: absolute;
					font-size: 24upx;
					font-family: Noto Sans S Chinese;
					font-weight: 400;
					color: #ABABAB;
					bottom: 0;
					right: 0;
					display: flex;
					align-items: center;
				}

			}
		}
	}
</style>
